import React, {Component} from 'react';
import NoHouse from "./components/NoHuse/NoHouse";
import {get} from "../../netWork";
import NavHeader from "../../components/NavHeader/NavHeader";
import {getToken} from "../../utiles/token";
class Rent extends Component {
    state = {
        myhouse: [],
        status:null
    };

    componentDidMount() {
        this.getMyHouse()
    }
    //获取已发布的房源
    getMyHouse = () =>{
        var value = getToken();
        get({
            url:'/user/houses',
            headers:{authorization:value }
        }).then(res =>{
            if(res.status === 400){
                this.setState({status:res.status})
            }else if(res.status === 200){
                this.setState({myhouse:res.body})
            }
        })
    }

    render() {
        const {myhouse} = this.state;
        console.log(myhouse);
        return (
            <div>
                <NavHeader>房屋发布</NavHeader>
                {/* {this.state.myhouse ? <HouseItem houseList={this.state.myhouse}/> :   <NoHouse/>   } */}
                <NoHouse/>
            </div>
        );
    }
}

export default Rent;
